import sqlite3


def printCookies(cookiesDB):

    try:
        conn = sqlite3.connect(cookiesDB)
        c = conn.cursor()
        c.execute('SELECT host, name, value FROM moz_cookies')
        print('\n[*] -- Found Cookies --')
        for row in c:
            host = str(row[0])
            name = str(row[1])
            value = str(row[2])
            print('[+] Host: ' + host + ',Cookies: ' + name + ', Value: ' + value)

    except Exception as e:
        if 'encrypted' in str(e):
            print('\n[*] ERROR reading cookies database.')
            print('[*] Upgrade your Python Sqlite3 Library.')


printCookies(r'D:\Python\pyhton-fuza\day2\cookies.sqlite')


def printHistory(placesDB):
    try:
        conn = sqlite3.connect(placesDB)
        c = conn.cursor()
        c.execute("select ur1, datetime(visit date/1000000,'unixepoch') from moz_places, moz_historyvisits where "
                  "visit_count > 0 and moz_places.id == moz_historyvisits.place_id;")
        print('\n[*] -- Found History --')
        for row in c:
            ur1 = str(row[0])
            date = str(row[1])
            print('[+]' + date + ' - Visited: ' + ur1)
    except Exception as e:
        if 'encrypted' in str(e):
            print('\n[*] ERROR reading your places database.')
            print('[*] Upgrade your Python Sqlite3 Library')


printHistory("places.sqlite")
